/////////////////////////////////
//该程序实现S2，S3，S4的消抖
/////////////////////////////////
module xd(clk_out3,key_out[2:0],key_in[2:0],key_s);
input clk_out3;
input [2:0] key_in;
output [2:0] key_out;
output key_s;
reg [2:0] dout1,dout2,dout3,key_out1;
reg key_s=1'd1;
wire [2:0] key_out;
assign key_out=(dout1|dout2|dout3);

always @ (posedge clk_out3)//3次采样
begin
	dout1<=key_in;
	dout2<=dout1;
	dout3<=dout2;
end
////乒乓操作
always@(negedge key_out[2])
begin
	key_s=~key_s;
end

endmodule
